"""
Case Type   : security-auditing
Case Name   : 审计目录下审计文件的最大数量设置1048577，不支持
Create At   : 2024/7/4
Owner       : wan005
Description :
    1.设置参数audit_file_remain_threshold=1048577
Expect      :
    1.返回取值范围错误的相关信息
History     :
    modified：2024/06/28 by 30044860 audit_file_remain_threshold取值范围变更为(100 .. 1048576)，优化用例
"""
import unittest
import datetime
from yat.test import Node
from yat.test import macro

from testcase.utils.Common import Common
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Logger import Logger


class Auditing(unittest.TestCase):
    def setUp(self):
        self.logger = Logger()
        self.logger.info(
            '-----Opengauss_Function_Security_Auditing_Case0113 start-----')
        self.sh_primy = CommonSH('PrimaryDbUser')
        self.userNode = Node('PrimaryDbUser')
        self.common = Common()
        self.DB_ENV_PATH = macro.DB_ENV_PATH

    def test_security(self):
        sql_cmd1 = f'source {self.DB_ENV_PATH};' \
                   f'gs_guc set -N all -I all -c ' \
                   f'"audit_file_remain_threshold=1048577"'
        msg1 = self.userNode.sh(sql_cmd1).result()
        self.logger.info(msg1)
        self.assertTrue(msg1.find(
            'The value 1048577 is outside the valid range for parameter '
            '"audit_file_remain_threshold" (100 .. 1048576)') > -1)

    def tearDown(self):
        self.logger.info(
            '------Opengauss_Function_Security_Auditing_Case0113 end------')
